package edu.pku.sei.autounit.generator;

import edu.pku.sei.autounit.core.Variable;
import edu.pku.sei.autounit.core.VariableFactory;
import edu.pku.sei.autounit.core.VariableGenerator;
import edu.pku.sei.autounit.filter.Filter;
import edu.pku.sei.autounit.reflect.Array;
import edu.pku.sei.autounit.reflect.Type;
import edu.pku.sei.autounit.util.NameFactory;
import edu.pku.sei.autounit.util.Properties;

public class ArrayGenerator implements VariableGenerator{

	public Variable generate(Type type, String name, VariableFactory vf,
			NameFactory nf) {

		if(type instanceof Array){
			Array array = (Array) type;
			Type e = array.getElementType();
			int l = Properties.getArraySize();
			Variable [] vs = new Variable[l];
			for(int i = 0;i<vs.length;i++)
				vs[i] = vf.getVariable
					(e, nf.getName(e.getFullName(), NameFactory.ELEMENT), vf, nf);
			return new ArrayVariable(array, name, vs);
		}
		return null;
	}


	public Variable generate(Type type, String name, Filter fliter,
			VariableFactory vf, NameFactory nf) {
		// TODO Auto-generated method stub
		return null;
	}

}
